package com.cll.pmis.entity;

import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.enums.IdType;
import com.cll.pmis.common.validator.group.Insert;
import com.cll.pmis.common.validator.group.Update;
import io.github.llchen.apidoc.annotation.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 * 
 * </p>
 *
 * @author chenliangliang
 * @since 2018-06-18
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(description = "药品表")
public class Drug implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    @NotNull(message = "药品id不能为空",groups = {Update.class})
    private Integer id;

    @NotBlank(message = "药品名不能为空",groups = {Insert.class})
    private String name;
    /**
     * 规格
     */
    private String specification;
    /**
     * 计量单位
     */
    private String unit;
    /**
     * 数量
     */
    @Range(max = Integer.MAX_VALUE,message = "药品数量要大于0",groups = Insert.class)
    @NotNull(message = "药品数量必须指定",groups = Insert.class)
    private Integer num;

    @TableField(exist = false)
    private Integer outputNum;


    /**
     * 冻结数量
     */
    @JSONField(serialize = false)
    private Integer freeze;
    /**
     * 生产厂商
     */
    private String provider;
    /**
     * 成本价
     */
    @NotNull(message = "成本价不能为空",groups = Insert.class)
    private BigDecimal costPrice;
    /**
     * 销售价格
     */
    @NotNull(message = "销售价格不能为空",groups = Insert.class)
    private BigDecimal sellPrice;
    /**
     * 批号
     */
    private String lotNum;
    /**
     * 类型
     */
    @NotNull(message = "药品类型必须指定",groups = Insert.class)
    private Integer type;
    /**
     * 生产日期
     */
    @JSONField(format = "yyyy-MM-dd")
    @NotNull(message = "生产日期必须指定",groups = Insert.class)
    private Date productTime;
    /**
     * 过期时间
     */
    @JSONField(format = "yyyy-MM-dd")
    @NotNull(message = "过期日期必须指定",groups = Insert.class)
    private Date overTime;
    /**
     * 创建时间
     */
    private Date createTime;
    /**
     * 更新时间
     */
    private Date updateTime;

    @TableField(exist = false)
    private BigDecimal cost;


}
